
// Source File Name:   BLImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            BLCommonImpl, ANYImpl, CSImpl, TYPEImpl

public class BLImpl extends BLCommonImpl
    implements BL
{

    public static final String RCS_ID = "$Header: BLImpl.java 115.14 2005/09/16 09:23:44 amchanda noship $";
    public static final BLImpl TRUE = new BLImpl(true);
    public static final BLImpl FALSE = new BLImpl(false);
    private static final BL nullNI = new BLImpl(CSImpl.valueOf("NI"));
    private static final BL nullOTH = new BLImpl(CSImpl.valueOf("OTH"));
    private static final BL nullNINF = new BLImpl(CSImpl.valueOf("NINF"));
    private static final BL nullPINF = new BLImpl(CSImpl.valueOf("PINF"));
    private static final BL nullUNK = new BLImpl(CSImpl.valueOf("UNK"));
    private static final BL nullASKU = new BLImpl(CSImpl.valueOf("ASKU"));
    private static final BL nullNAV = new BLImpl(CSImpl.valueOf("NAV"));
    private static final BL nullMSK = new BLImpl(CSImpl.valueOf("MSK"));
    private static final BL nullNA = new BLImpl(CSImpl.valueOf("NA"));
    private static final BL nullNASK = new BLImpl(CSImpl.valueOf("NASK"));

    public static BL valueOf(boolean flag)
    {
        if(flag)
            return TRUE;
        else
            return FALSE;
    }

    public static BL valueOf(String s)
    {
        if(BLCommonImpl.toBoolean(s))
            return TRUE;
        else
            return FALSE;
    }

    public static BL nullBL()
    {
        return new BLImpl(((CS) (null)));
    }

    public BLImpl(boolean flag)
    {
        super(flag);
    }

    public BLImpl(CS cs)
    {
        super(cs);
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.BL;
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof BL))
            return FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return FALSE;
        } else
        {
            BL bl = (BL)any;
            return valueOf(isTrue() == bl.isTrue());
        }
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
            i += _value ? 1 : 0;
        return i;
    }

    public static BL nullBL(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
